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VVALLIIHBGEZLGRHRCKGF",
"LXYPCVPNUKSWCCGXEYTEBAWRLWDWNHHNNNWQNIIBUCGUJYMRYW",
"CZDKISKUSBPFHVGSAVJBDMNPSDKFRXVVPLVAQUGVUJEXSZFGFQ",
"IYIJGISUANRAXTGQLAVFMQTICKQAHLEBGHAVOVVPEXIMLFWIYI",
"ZIIFSOPCMAWCBPKWZBUQPQLGSNIBFADUUJJHPAIUVVNWNWKDZB",
"HGTEEIISFGIUEUOWXVTPJDVACYQYFQUCXOXOSSMXLZDQESHXKP",
"FEBZHJAGIFGXSMRDKGONGELOALLSYDVILRWAPXXBPOOSWZNEAS",
"VJGMAOFLGYIFLJTEKDNIWHJAABCASFMAKIENSYIZZSLRSUIPCJ",
"BMQGMPDRCPGWKTPLOTAINXZAAJWCPUJHPOUYWNWHZAKCDMZDSR",
"RRARTVHZYYCEDXJQNQAINQVDJCZCZLCQWQQIKUYMYMOVMNCBVY",
"ABTCRRUXVGYLZILFLOFYVWFFBZNFWDZOADRDCLIRFKBFBHMAXX",
	};


int check(int x,int y)
{
	int ans=0;
	for(int i=x;i<30;i++){
		if(a[i][y]>a[x][y])
			ans++;
	}
	for(int i=y;i<50;i++){
		if(a[x][i]>a[x][y])
			ans++;
	}
	for(int i=x,j=y;i<30&&j<50;i++,j++){
		if(a[i][j]>a[x][y])
			ans++;
	}
	for(int i=x,j=y;i<30&&j>=0;i++,j--){
		if(a[i][j]>a[x][y])
			ans++;
	}
  for(int i=x,j=y;i>=0&&j<50;i--,j++){
		if(a[i][j]>a[x][y])
			ans++;	
	}
	return ans;
}

	
int main()
{
	
	int sum=0;
	for(int i=0;i<30;i++){
		for(int j=0;j<50;j++){
			sum+=check(i,j);
		}
	}
	printf("%d",sum);
	return 0;
}
